package com.neu.his.disease.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.his.commonutils.R;
import com.neu.his.disease.entity.Disease;
import com.neu.his.disease.service.DiseaseService;

@RestController
@CrossOrigin
@RequestMapping("/his/disease")
public class DiseaseController {
	@Autowired
	private DiseaseService diseaseService;
//		根据疾病分类查询疾病信息 并分页
	@GetMapping("/getdiseaseInfo")
	public R getdiseaseInfo(int diseCategoryID,int page,int limit) {
		page = (page-1)*limit;
		List<Disease> disease =  diseaseService.getdiseaseInfo(diseCategoryID, page, limit);
		int total = diseaseService.getdiseaseInfoTotal(diseCategoryID);
		return R.ok().data("disease", disease).data("total", total);
	}
//	添加疾病信息
	@PostMapping("/addDisease")
	public R addDisease(@RequestBody Disease disease) {
		boolean flag = diseaseService.addDisease(disease);
		return R.ok().data("flag", flag);
	}
//	批量删除多个
	@PostMapping("/delDiseaseByIds")
	public R delDiseaseByIds(@RequestBody Integer [] ids) {
		boolean flag = diseaseService.delDiseaseByIds(ids);
		return R.ok().data("flag", flag);
	}
//	修改疾病信息
	@PostMapping("/updateDisease")
	public R updateDisease(@RequestBody Disease disease) {
		boolean flag = diseaseService.updateDisease(disease);
		return R.ok().data("flag", flag);
		
		
	}
	
}
